//
// Created by hjie on 23-7-23.
//
#include <cstring>
#include <iostream>
#include <string>
#include "./../base/link.h"

void FindMeddleNodeList()
{
    int length = rand() % 15;
    LinkList list = {};

    NoSortLinkList(list, length);
    PrintLinkList(list);

    LinkNode * fast_node = list.head_node;
    LinkNode * slow_node = list.head_node;

    while(fast_node->next_node)
    {
        slow_node = slow_node->next_node;
        fast_node = fast_node->next_node;
        if (fast_node)
        {
            fast_node = fast_node->next_node;
        }
    }
    printf("\n%d.\n", slow_node->data);
}

int main(int argc, const char * argv[])
{
    FindMeddleNodeList();
    return EXIT_SUCCESS;
}